
//请求次数
let requestTimes = 0

export function request1(config){
  //加载样式
  wx.showLoading({
    title: '加载中..',
  })
  return new Promise((result,reject) => {
    //  请求次数加加加
    requestTimes++
    wx.request({
      ...config,
      success(res){
        result(res)
      },
      //每次执行了请求都会触发这个函数
      complete(){
        requestTimes--
        if(requestTimes == 0){
          wx.hideLoading()
        }
      }
    })
  })
}

export function address(address){
  return address.cityName + address.countyName + address.detailInfo
}

export function modal({title}){
  return new Promise((result,reject) => {
    wx.showModal({
      title: '提示',
      content: title,
      success (res) {
        result(res)
      },
      fail (res) {
        reject(res)
      }
    })
  })
}